/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package example12_6;

import java.util.Stack;

/**
 *
 * 创建两个线程writeThread和readThread对stack进行操作，
 * 使用synchronized关键字保证对stack进行操作的线程互斥，同一时刻只能有一个线程对stack进行读或写操作，
 * 使用wait()方法使得本线程等待，
 * 使用notify()方法使得处于等待中的线程结束等待。
 * @author apple
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Stack<Integer> stack=new Stack<Integer>();
        WriteStack writeThread=new WriteStack(stack,"WriteThread");
        ReadStack readThread=new ReadStack(stack, "ReadThread");
        writeThread.start();
        readThread.start();
    }
}
